Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
React Native (React Navigation)<> Firebase login screen

I'm using Firebase to keep track of all the users. I was able to connect Firebase. User registration is working fine.

I'm having issues with logging the users. When I enter login and password, the app doesn't redirect me to the right screen, and also throws this warning [Unhandled promise rejection: TypeError: navigation.navigation is not a function. (In 'navigation.navigation("myProfile")', 'navigation.navigation' is undefined)]

Here is how I do it

import { useNavigation } from "@react-navigation/native";
import React, { useEffect, useState } from "react";
import { View, ...} from "react-native";
import { auth } from "../firebase";

const Profile = () => {
  const [email, setEmail] = useState("");
  const [password, setPassword] = useState("");

  const navigation = useNavigation();

   useEffect(() => {
     const unsubscribe = auth.onAuthStateChanged((user) => {
       if (user) {
         navigation.navigation("myProfile");
       }
     });
     return unsubscribe;
   }, []);


  const signIn = () => {
    auth
      .signInWithEmailAndPassword(email, password)
      .then((userCredentials) => {
        const user = userCredentials.user;
        console.log("Sign In user.email = " + user.email);
      })
      .catch((error) => alert(error.message));
  };
//more code 

I also tried this, but it didn't help

import React, { useEffect, useState } from "react";
import { View, ...} from "react-native";
import { auth } from "../firebase";

const Profile = ({navigation}) => {
  const [email, setEmail] = useState("");
  const [password, setPassword] = useState("");
    
   useEffect(() => {
     const unsubscribe = auth.onAuthStateChanged((user) => {
       if (user) {
         navigation.navigation("myProfile");
       }
     });
     return unsubscribe;
   }, []);

//more code 

I'm not sure if I need to navigation.navigation("myProfile") onPress or it has to be inside of the the useEffect

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use

navigation.navigate("myProfile")

instead of

navigation.navigation("myProfile");

Also you can destruct your hook object like this

const { navigate } = useNavigation()

in order to just write

navigate("myProfile")

I'm not sure if I need to navigation.navigation("myProfile") onPress or it has to be inside of the the useEffect

Most of the cases you should move the user to home screen (logged in user screen) when the signIn function returns true and the user is logged in, so in this case I think you have to use navigate("myProfile") inside of

auth
  .signInWithEmailAndPassword(email, password)
  .then((userCredentials) => {
    ...your code
    navigation.navigate("myProfile")
  })
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda